package com.jit.baselib.ui.base;

import android.content.Context;

import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;

/**
 * @author crazyZhangxl on 2019/1/15.
 */
public abstract class BaseObserver<T> implements Observer<T> {

    @Override
    public void onSubscribe(Disposable d) {

    }

    /**
     * 必须实现onNext
     * @param t
     */
    @Override
    public abstract void onNext(T t);

    @Override
    public void onError(Throwable e) {
        if(e instanceof ExceptionHandle.ResponseException){
            onError((ExceptionHandle.ResponseException)e);
        }else{
            onError(new ExceptionHandle.ResponseException(e,ExceptionHandle.ERROR.UNKNOWN));
        }
    }
    @Override
    public void onComplete() {

    }
    public abstract void onError(ExceptionHandle.ResponseException exception);

}
